<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<%@taglib prefix="priv" uri="/mytag/privilege"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>系统资源管理页面</title>
<script type="text/javascript" src="${path}/js/scripts/bootstart.js"></script>
</head>
<body style="width: 98%; height: 90%;">
	<div style="width: 100%;">
		<div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
			<table style="width: 100%;">
				<tr>
					<td style="width: 100%;"><priv:priv-btn btnname="add">
							<a class="mini-button" iconCls="icon-add"
								onclick="griddata.add()">增加</a>&nbsp;</priv:priv-btn>
						<priv:priv-btn btnname="edit">
							<a class="mini-button" iconCls="icon-add"
								onclick="griddata.edit()">修改</a>&nbsp;</priv:priv-btn> <priv:priv-btn
							btnname="remove">
							<a class="mini-button" iconCls="icon-remove"
								onclick="griddata.remove()">删除</a>&nbsp;</priv:priv-btn></td>
				</tr>
			</table>
		</div>
	</div>
	<div id="resourceGrid" class="mini-treegrid"
		style="width: 100%; height: 98%;" expandOnLoad="true"
		url="${path }/resource/mgr/showList" showTreeIcon="true"
		dataField="list" pageSize="100" treeColumn="taskname"
		idField="sourceId" parentField="parentId" resultAsTree="false">
		<div property="columns">
			<div type="checkcolumn" width="15"></div>
			<div field="sourceName" name="taskname" width="80"
				headerAlign="center">资源名称</div>
			<div field="path" headerAlign="center" width="100">路径</div>
			<div field="isUsed" width="25" headerAlign="center"
				renderer="griddata.isusedRenderer" allowSort="false">是否启用</div>
			<div field="functionNames" width="180" headerAlign="center">功能</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="${path}/js/scripts/datagrid.js"></script>
<script type="text/javascript" src="${path}/js/scripts/utils.js"></script>
<script type="text/javascript" src="${path}/js/message.js"></script>
<script type="text/javascript">
	var doc = $(document);
	$(function() {
		mini.parse();
		$.grid.datagrid = mini.get("resourceGrid");
		window.griddata = {}; //window對象下創建一個griddata對象
		griddata.add = function() {
			$.grid.add({
				url : "${path}/resource/mgr/resourceform",
				width : doc.width() * 0.7 + "px",
				height : doc.height() + "px",
				title : "资源添加"
			});
		};

		griddata.edit = function() {
			$.grid.edit({
				url : "${path}/resource/mgr/resourceform",
				title : "资源修改",
				formId : "resourceForm",
				fieldId : "sourceId",
				width : doc.width() * 0.7 + "px",
				height : doc.height() + "px",
				dataUrl : "${path}/resource/mgr/showUpdate"
			});
		};

		griddata.remove = function() {
			var datagrid = mini.get("resourceGrid").getSelected();
			if (!datagrid) {
				mini.alert("请选择你要删除的行!");
				return;
			}

			if (datagrid.children) {
				mini.alert("您选中的记录存在子项，请先删除其子项！");
				return;
			}

			$.grid.remove({
				url : "${path}/resource/mgr/deleteResource",
				paramName : "key", //获取参数的参数名
				showMsg : true,//是否显示提示信息（删除成功与否返回信息）
				fldId : "sourceId" //獲取選中列的主鍵值對應的列名
			});
		};
		griddata.isusedRenderer = function(e) {
			if (e.value == 1) {
				return "启用";
			}
			return "停用";
		};
	});
</script>
</html>